import request from '@/utils/requestH2'

/* 仓库 */

// 可新建的入库单查询
export function selCanEnterWarehouseListApi() {
  return request({
    url: '/buyGoods/selCanEnterWarehouseList',
    method: 'GET'
  })
}

// 获取入库仓库列表
export function selEnterWarehouseListApi(params) {
  return request({
    url: '/buyGoods/selEnterWarehouseList',
    method: 'GET',
    params
  })
}

// 新增入库仓库
export function addEnterWarehouseApi(data) {
  return request({
    url: '/buyGoods/addEnterWarehouse',
    method: 'POST',
    data
  })
}

// 根据id修改入库仓库
export function updateEnterWarehouseByIdApi(data,id) {
  return request({
    url: `/buyGoods/updateEnterWarehouseById/${id}`,
    method: 'PUT',
    data
  })
}

// 根据ids删除入库仓库
export function delEnterWarehouseByIdApi(id) {
  return request({
    url: `/buyGoods/delEnterWarehouseById/${id}`,
    method: 'DELETE'
  })
}

// 根据id处理入库单
export function handleEnterWarehouseByIdApi(data) {
  return request({
    url: `/buyGoods/updateEnterWarehouseStatusById/${data.id}`,
    method: 'PUT',
    data: {
      operatorId: data.operatorId, // 操作员
      remark: data.remark // 备注
    }
  })
}

/* 出库仓库 */

// 可新建的出库单查询
export function selCanOutWarehouseListApi() {
  return request({
    url: '/buyGoods/selCanOutWarehouseList',
    method: 'GET'
  })
}

// 获取出库仓库列表
export function selOutWarehouseListApi(params) {
  return request({
    url: '/buyGoods/selOutWarehouseList',
    method: 'GET',
    params
  })
}

// 新增出库仓库
export function addOutWarehouseApi(data) {
  return request({
    url: '/buyGoods/addOutWarehouse',
    method: 'POST',
    data
  })
}

// 根据id修改出库仓库
export function updateOutWarehouseByIdApi(id,data) {
  return request({
    url: `/buyGoods/updateOutWarehouseById/${id}`,
    method: 'PUT',
    data
  })
}

// 根据ids删除出库仓库
export function delOutWarehouseByIdApi(id) {
  return request({
    url: `/buyGoods/delOutWarehouseById/${id}`,
    method: 'DELETE'
  })
}

// 根据id处理出库单
export function handleOutWarehouseByIdApi(data) {
  return request({
    url: `/buyGoods/updateOutWarehouseStatusById/${data.id}`,
    method: "PUT",
    data: {
      operatorId: data.operatorId, // 操作员
      remark: data.remark, // 备注
    },
  });
}

// 库存余额列表查询
export function selInventoryListApi(params) {
  return request({
    url: '/inventory/inventory/selInventoryList',
    method: 'GET',
    params
  })
}

// 新增商品库存
export function addInventoryApi(data) {
  return request({
    url: '/inventory/inventory/addInventory',
    method: 'POST',
    data
  })
}

// 根据id修改商品库存
export function updateInventoryByIdApi(data) {
  return request({
    url: `/inventory/inventory/updateInventoryById/${data.id}`,
    method: 'PUT',
    data: {
      goodsId: data.goodsId, // 商品
      number: data.number, // 数量
      warehouseId: data.warehouseId // 仓库
    }
  })
}

// 根据ids删除商品库存
export function delInventoryByIdApi(id) {
  return request({
    url: `/inventory/inventory/delInventoryById/${id}`,
    method: 'DELETE'
  })
}

